<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>构造函数</title>
</head>
<body>
    
</body>
</html>

<script>
    //禁止constructor被遍历
    function User(){}
    User.prototype.name = function(){
        console.log("user.name");
    }

    function Admin(){}
    //修改admin的原型为User
    Admin.prototype = Object.create(User.prototype);
    Admin.prototype.constructor = Admin;
    // console.log(Object.getOwnPropertyDescriptors(Admin.prototype));
    //规定构造函数是不能被遍历的
    Object.defineProperty(Admin.prototype,"constructor",{
        value:Admin,
        enumerable:false
    });
    Admin.prototype.role = function(){
        console.log("admin.role");
    }
    // console.log(Object.getOwnPropertyDescriptors(Admin.prototype));
    let a = new Admin();
    for(const key in a){
        console.log(key);
    }
</script>